package Solutions

func reverseList(head *ListNode) *ListNode {
	t, h := _reverse(head)
	if t != nil {
		t.Next = nil
	}

	return h
}

func _reverse(head *ListNode) (*ListNode, *ListNode) {
	if head == nil {
		return nil, nil
	}
	if head.Next == nil {
		return head, head
	}
	last, h := _reverse(head.Next)
	last.Next = head
	return head, h
}
